package be.ipl.finito.domaine;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@SuppressWarnings("serial")
@Entity
@Table(name = "CASES_PLATEAUX", schema = "FINITO")
public class Case implements Serializable {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id_case_plateau;

	@NotNull
	@ManyToOne
	@JoinColumn(name = "PLATEAU")
	private Plateau plateau;

	@NotNull
	@ManyToOne
	@JoinColumn(name = "JETON")
	private Jeton jeton;

	@NotNull
	@Min(1)
	@Max(36)
	private int indice_case_jeton;

	public Case(Jeton jeton, Plateau plateau, int indice_case_jeton) {
		this.jeton = jeton;
		this.plateau = plateau;
		this.indice_case_jeton = indice_case_jeton;
	}

	protected Case() {
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id_case_plateau;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Case other = (Case) obj;
		if (id_case_plateau != other.id_case_plateau)
			return false;
		return true;
	}

	public int getId() {
		return id_case_plateau;
	}

	public Plateau getPlateau() {
		return plateau;
	}

	public void setPlateau(Plateau plateau) {
		this.plateau = plateau;
	}

	public Jeton getJeton() {
		return jeton;
	}

	public void setJeton(Jeton jeton) {
		this.jeton = jeton;
	}

	public int getCasePlateau() {
		return id_case_plateau;
	}

	public int getIndiceCaseJeton() {
		return indice_case_jeton;
	}

	public void setIndiceCaseJeton(int indice_case_jeton) {
		this.indice_case_jeton = indice_case_jeton;
	}

}
